//
//  BDSubtitleTableViewCell.m
//  BadBoy
//
//  Created by wen on 2017/3/16.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDSubtitleTableViewCell.h"

@interface BDSubtitleTableViewCell ()

@property (nonatomic, strong) UIImageView *righImage;

@end

@implementation BDSubtitleTableViewCell

+ (CGFloat)getCellHeightWithModel:(id)model{
    return 40;
}

- (void)configeWithModel:(id)model{
    //@"image":@"dianhua_2", @"title":self.detailModel.phone, @"subTitle":ASLocalizedString(@"联系商家"),@"needRight":@"1"
    self.imageView.image = [UIImage imageNamed:model[@"image"]];
    self.textLabel.text = model[@"title"];
    self.detailTextLabel.text = model[@"subTitle"];
    if (model[@"needRight"]) {
        self.righImage.hidden = NO;
    }else{
        self.righImage.hidden = YES;
    }
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.imageView.size = CGSizeMake(20, 20);
    self.imageView.left = 10;
    self.imageView.centerY = self.height / 2.0;
    
    self.textLabel.font = [UIFont systemFontOfSize:14];
    self.textLabel.textColor = kBDTimeColor;
    [self.textLabel sizeToFit];
    self.textLabel.left = self.imageView.right + 10;
    self.textLabel.centerY = self.imageView.centerY;
    
    self.righImage.size = CGSizeMake(15, 15);
    self.righImage.right = self.width - 10;
    self.righImage.centerY = self.imageView.centerY;
    
    self.detailTextLabel.font = [UIFont systemFontOfSize:13];
    
    [self.detailTextLabel sizeToFit];
    
    self.detailTextLabel.centerY = self.imageView.centerY;
    if (self.righImage.hidden == NO) {
        self.detailTextLabel.right = self.righImage.left - 5;
        self.detailTextLabel.textColor = KBDColorBlue;
    }else{
        self.detailTextLabel.right = self.righImage.right;
        self.detailTextLabel.textColor = [UIColor orangeColor];
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    style = UITableViewCellStyleValue1;
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
    }
    return self;
}

-(UIImageView *)righImage{
    if (!_righImage) {
        _righImage = [[UIImageView alloc]init];
        _righImage.image = [UIImage imageNamed:@"righ"];
        [self.contentView addSubview:_righImage];
    }
    return _righImage;
}

@end
